package com.csu.letaobackend.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.csu.letaobackend.bean.Coupon;
import com.csu.letaobackend.bean.User;
import com.csu.letaobackend.commom.CommonResponse;
import com.csu.letaobackend.service.CouponService;
import com.csu.letaobackend.vo.CouponVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Controller
@CrossOrigin
@RequestMapping("/coupon")
public class CouponController {

      @Autowired
      CouponService couponService;

      @GetMapping("/coupons")
      @ResponseBody
      public CommonResponse<List<CouponVO>> getCouponsByUsername(HttpSession httpSession) {
            User login_user = (User) httpSession.getAttribute("login_user");
            return couponService.getCouponsByUsername(login_user.getUsername());
      }
}
